//
//  UIScrollView+XDScrollView.m
//  TheRicher
//
//  Created by 李晓东 on 2018/1/31.
//  Copyright © 2018年 PeanutXu. All rights reserved.
//

#import "UIScrollView+XDScrollView.h"

@implementation UIScrollView (XDScrollView)

- (void)loadMore {
    self.indicatorView = [[UIActivityIndicatorView alloc]init];
    [self.indicatorView setColor:[UIColor blueColor]];
    [self.indicatorView setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
    [(UITableView *)self setTableFooterView:self.indicatorView];
    
}

- (void)setRefreshingView:(XDRefreshingView *)refreshingView{
    [self addSubview:refreshingView];
}

- (void)scrollToEnd:(LoadMoreFromDatabaseBlock)block{
    CGFloat scrollHeight = self.frame.size.height;
    CGFloat contentOffsetY = self.contentOffset.y;
    if (self.contentSize.height - contentOffsetY  < scrollHeight - 60) {
        block();
    }
    
}
@end
